package com.ys.web.pay.job;

import com.ys.utils.base.j2se.Logger;
import com.ys.utils.spring.properties.Config;
import com.ys.web.pay.service.TransferService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 红包定时任务
 */
@Component
@Slf4j
public class TransferTask implements Job {

    @Autowired
    private TransferService transferService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        if (Boolean.parseBoolean(Config.pp.get("trading.disable"))) {
            log.info("转账定时任务,交易系统已关闭");
            return;
        }
        if(!Logger.isOnline()){
            log.info("转账定时任务---当前环境为研发环境----结束");
            return;
        }
        transferService.transferGoBack();
    }
}
